package lab5;

public class CashRegister {
	/**
	 * Default constructor
	 */
	public CashRegister() {
		
		register.addBills(100);
		register.addDimes(100);
		register.addNickels(100);
		register.addPennies(100);
		register.addQuarters(100);	
	}
	/**
	 * 
	 * @param registerTotal Create new register with previous values
	 */
	public CashRegister(Cash registerTotal) {

		register.addBills(registerTotal.getBills());
		register.addDimes(registerTotal.getDimes());
		register.addNickels(registerTotal.getNickels());
		register.addPennies(registerTotal.getPennies());
		register.addQuarters(registerTotal.getQuarters());	
	}
	
	/**
	 * 
	 * @param amount Amount to spend
	 * @return total debt after purchase
	 */
	public double purchase(double amount) {
		purchase += amount;
		return purchase;
	}
	
	/**
	 * 
	 * @param amount Amount to deduce from debt
	 */
	public void payment(Cash amount) {
		customer.addBills(amount.getBills());
		customer.addDimes(amount.getDimes());
		customer.addNickels(amount.getNickels());
		customer.addPennies(amount.getPennies());
		customer.addQuarters(amount.getQuarters());
		register.add(customer);
		
	}
	/**
	 * 
	 * @return Money left from the custumer
	 */
	public Cash giveChange() {
		customer.remove(purchase);
		return customer;
	}
	/**
	 * 
	 * @return Total debt
	 */
	public double getPurchasedTotal() {
		return purchase;
	}
	
	/**
	 * 
	 * @return The amount paid
	 */
	public Cash getPayment() {
		return customer;
	}
	/**
	 * 
	 * @return Money in the register
	 */
	public Cash getRegisterTotal() {
		return register;
	}
	
	Cash customer = new Cash();
	Cash register = new Cash();
	private double purchase = 0;
}
